#coding=UTF-8
require 'rexml/document'
include REXML


file = File.new("Competences.xml")
doc = Document.new(file)
root = doc.root
root.each_element do |e|
   idC = e.elements["@idC"]
   STDOUT.reopen("./CvCompetence/#{idC}.html")
   system("xsltproc Personnes.xsl Personnes.xml --stringparam idC #{idC}")
end


file = Dir.new("./Cv_xml")

file.each do |path|
  if path != "." and path != ".." and File.extname(path)== ".xml"
    sortie = "./CV/#{path.reverse[4, path.size].reverse}.html"
    File::open(sortie, File::WRONLY | File::CREAT) do |fic_out|
      STDOUT.reopen(fic_out)
      system("xsltproc CV.xsl ./Cv_xml/#{path}")
    end
  end
end


STDOUT.reopen("./LesCV/index.html")
system("xsltproc Personnes.xsl Personnes.xml")


STDOUT.reopen("./LesDomaines/index.html")
system("xsltproc Competences.xsl Competences.xml")

type = ["Autre", "Langage", "Methode", "Outil", "Reseau", "SGBD"]


type.each do |e|
    STDOUT.reopen("./LesDomaines/#{e}.html")
    system("xsltproc Competences.xsl Competences.xml --stringparam type #{e}")
end


system("cp CV/* ../Site/CV/")
system("cp CvCompetence/* ../Site/CvCompetence/")
system("cp LesCV/* ../Site/LesCV/")
system("cp LesDomaines/* ../Site/LesDomaines/")

